import { Module } from "@nestjs/common";
import { AuthService } from "./auth.service";
import { JwtModule } from "@nestjs/jwt";
import { configuration } from "../../../config/config";
import { UserModule } from "@app/user";
import { APP_GUARD } from "@nestjs/core";
import { AuthGuard } from "./auth.guard";
import { jwtConstants } from "@app/auth/constants";
import { LogModule } from "@app/log";
import { EnumMicroService } from "../../../types/types";

@Module({
  imports: [
    UserModule,
    LogModule.register(EnumMicroService.gateway),
    JwtModule.register({
      global: true,
      secret: jwtConstants.secret,
      signOptions: { expiresIn: configuration.token_expires_in },
    }),
  ],
  providers: [
    AuthService,
    {
      provide: APP_GUARD,
      useClass: AuthGuard,
    },
  ],
  exports: [AuthService],
})
export class AuthModule {}
